package com.beijing.gaoji;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author Ma Wenqi
 * @Date 2021/3/27 19:55
 * @Version 1.0
 */
public class TestPool {
    public static void main(String[] args) {
        //1.创建服务，创建线程池
        ExecutorService service = Executors.newFixedThreadPool(10);  //newFixedThreadPool的参数为线程池大小

        //执行
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());

        //2.关闭连接
        service.shutdown();
    }
}

class MyThread implements Runnable {

    @Override
    public void run() {

            System.out.println(Thread.currentThread().getName());
    }
}